<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>0</h1>
</body>
<script>
  let count = 0;
  setInterval(f, 1000);
  let h = document.querySelector("h1")
  function f() {
    count++;
    h.innerText = count;
  }

  let a = setInterval(function () {
    if (count == 10) {
      clearInterval(a)
    }
    console.log(count);
  },1000)

  setTimeout(function () {
    alert("时间到");
  },5000)
</script>
</html>